package com.yunji.base.provide;

import com.yunji.base.service.StaffService;
import com.yunji.common.model.domain.StaffDO;
import com.yunji.common.model.enums.LoginTypeEnum;
import com.yunji.system.context.SystemUtil;
import com.yunji.system.service.TokenService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : peter-zhu
 * @date : 2024/12/12 15:34
 * @description : TODO
 **/
@Component
public class BaseDataStaffProvide {

    @Resource
    StaffService staffService;

    public void deleteStaffTokenByBelongId(Long belongId) {
        List<StaffDO> staffList = staffService.listByBelongId(belongId);
        for (StaffDO staff : staffList) {
            SystemUtil.redisCache().delete(TokenService.getTokenKey(LoginTypeEnum.STAFF, staff.getId()));
        }
    }

    public List<StaffDO> listByManagerId(Long managerId) {
        return staffService.listByManagerId(managerId);
    }
}
